package com.x.bff.app.controller;

import com.x.bff.app.model.vo.mc.SendImRequestVO;
import com.x.bff.app.service.mc.MessageService;
import com.x.core.web.api.R;
import com.x.core.web.controller.BaseFrontendController;
import com.x.provider.api.mc.model.dto.MessageDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "消息服务")
@Slf4j
@RestController
@RequestMapping("/app/message")
public class MessageController extends BaseFrontendController {

    private final MessageService messageService;

    public MessageController(MessageService messageService){
        this.messageService = messageService;
    }

    @ApiOperation(value = "发送私信")
    @PostMapping("/im/send")
    public R<MessageDTO> create(@RequestBody @Validated SendImRequestVO reqVO){
        reqVO.setCustomerId(getCurrentCustomerId());
        return R.ok(messageService.sendMessage(reqVO));
    }

}
